package com.stylefeng.guns.modular.system.service.impl;

import java.util.Date;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.stylefeng.guns.core.shiro.ShiroKit;
import com.stylefeng.guns.core.shiro.ShiroUser;
import com.stylefeng.guns.modular.system.dao.MyGpcMapper;
import com.stylefeng.guns.modular.system.model.MyGpc;
import com.stylefeng.guns.modular.system.service.IMyGpcService;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author stylefeng123
 * @since 2018-07-02
 */
@Service
public class MyGpcServiceImpl extends ServiceImpl<MyGpcMapper, MyGpc> implements IMyGpcService {

	@Autowired
	private MyGpcMapper myGpcMapper;
	
	@Override
	public List<Map<String, Object>> selectMapsByDm(Page<MyGpc> page,
			String date, String dm) {
		ShiroUser shiroUser = ShiroKit.getUser();
		return myGpcMapper.selectMapsByDm(page,date,dm,shiroUser.getId());
	}

	@Override
	public boolean insertMyGpc(MyGpc myGpc) {
		ShiroUser shiroUser = ShiroKit.getUser();
		MyGpc nMyGpc = new MyGpc();
		nMyGpc.setgTdate(new Date());
		nMyGpc.setgUserid(shiroUser.getId());
		nMyGpc.setgScode(myGpc.getgScode());
		myGpc = myGpcMapper.selectOne(myGpc);
		if(myGpc == null){
			return myGpcMapper.insert(nMyGpc) > 0;
		}
		return true;
	}

	@Override
	public List<Map<String, Object>> selectByCurrentDayGpc(List<String> gScode,
			String gTime) {
		ShiroUser shiroUser = ShiroKit.getUser();
		return myGpcMapper.selectByCurrentDayGpc(gScode,gTime,shiroUser.getId());
	}

	@Override
	public List<Map<String, Object>> selectByCurrentFengKDayGpc(String gTime,Integer zlje,Integer mp) {
		return myGpcMapper.selectByCurrentFengKDayGpc(gTime,zlje,mp);
	}

}
